package com.hotel.service.impl;

import com.hotel.mapper.Item2Mapper;
import com.hotel.pojo.Item;
import com.hotel.service.Item2Service;
import com.hotel.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;

import java.util.Date;
import java.util.List;

@Service
public class Item2ServiceImpl implements Item2Service {
    @Autowired
    private Item2Mapper item2Mapper;

    @Override
    public List<Item> findAll() {
        return item2Mapper.findAll();
    }

    @Override
    public PageResult getItem2List(PageResult pageResult) {
        Long total = item2Mapper.getTotal();
        int size = pageResult.getPageSize();
        int start = (pageResult.getPageNum()-1)*size;
        String query = pageResult.getQuery();
        List<Item> rows = item2Mapper.findItem2ListByPage(start,size,query);
        return pageResult.setTotal(total).setRows(rows);
    }

    @Override
    public Item findItem2ById(Integer itemId) {
        return item2Mapper.findItem2ListById(itemId);
    }

    @Override
    public void deleteItem2(Integer itemId) {
        item2Mapper.deleteItem2(itemId);
    }

    @Override
    public void updateItem2(Item item) {
        item2Mapper.updateItem2(item);
    }

    @Override
    public void addItem2(Item item) {
        item2Mapper.addItem2(item);
    }
}
